#ifndef CCONSTDEFINITION_H
#define CCONSTDEFINITION_H

#include <Qt>

namespace cooking {

const int KRoleNumberPerTable = 50;

const int KCuisineRoleStart = Qt::UserRole + 1;

const int KRegionRoleStart = KCuisineRoleStart + KRoleNumberPerTable;

const int KRecipeRoleStart = KRegionRoleStart + KRoleNumberPerTable;

const int KIngredientRoleStart = KRecipeRoleStart + KRoleNumberPerTable;

const int KCookingTechiqueRoleStart = KIngredientRoleStart +KRoleNumberPerTable;

const int KMethodRoleStart = KCookingTechiqueRoleStart + KRoleNumberPerTable;

const int KPreparationTechiqueRoleStart = KMethodRoleStart + KRoleNumberPerTable;

const int KRecipeIngredientRoleStart = KPreparationTechiqueRoleStart + KRoleNumberPerTable;

const int KUtensilsRoleStart = KRecipeIngredientRoleStart + KRoleNumberPerTable;

const int KMealPlanRoleStart = KUtensilsRoleStart + KRoleNumberPerTable;

const int KMealRecipeRoleStart = KMealPlanRoleStart + KRoleNumberPerTable;

const int KPictureRoleStart = KMealRecipeRoleStart + 50;

const int KInvalidId = -1;

const int KOk = 0;

const QString KCObjectId("_ROWID_");

const QString KJoin(" JOIN ");

const QString KLeft(" LEFT ");

const QString KLeftJoin(KLeft + KJoin);

const QString KUnion(" UNION ");

const QString KOpAdd(" + ");

const QString KOpEqual(" = ");

const QString KOpMinus(" - ");

const QString KOpMod(" % ");

const QString KOpLess(" < ");

const QString KOpLessEqual(" <= ");

const QString KOpMore(" > ");

const QString KOpMoreEqual(" >= ");

const QString KOpNotEqual( " <> ");

const QString KOpMultiply(" * ");

const QString KOpDivide(" / ");

const QString KOn(" ON ");

const QString KAnd(" AND ");

const QString KOr(" OR ");

const QString KIn(" IN ");

const QString KNot(" NOT ");

const QString KMinus(" MINUS ");

const QString KIntersect(" INTERSECT ");

const QString KEqual(" = ");

const QString KDistinct(" DISTINCT ");

const QString KWhere(" WHERE ");

const QString KSelect("SELECT ");

const QString KUpdate("UPDATE ");

const QString KDelete("DELETE FROM ");

const QString KSet(" SET ");

const QString KInsert("INSERT INTO ");

const QString KValues(" VALUES ");

const QString KCreateTable("CREATE TABLE ");

const QString KTypeInt(" INTEGER ");

const QString KTypeStr(" TEXT ");

const QString KTypeFloat(" FLOAT ");

const QString KTypeDouble(" DOUBLE ");

const QString KNotNull(" NOT NULL ");

const QString KPrimaryKey(" PRIMARY KEY ");

const QString KAutoIncrement(" AUTOINCREMENT ");

const QString KAll(" * ");

const QString KFrom(" FROM ");

const QString KCountAll(" COUNT(*) ");

const QString KCount(" COUNT");

const QString KSum(" SUM");

const QString KOrderBy(" ORDER BY ");

const QString KGroupBy(" GROUP BY ");

const QString KHaving(" HAVING ");

const QString KDesc(" DESC ");

const QString KAsc(" ASC ");

const QString KSelectAllFrom(KSelect + KAll + KFrom);

const QString KDot(".");

const QString KAs(" AS ");

const QString KComma(",");

const QString KNullString("");

const QString KNull("NULL");

const QString KDbNullString("''");

const QString KPictureFolderName("Images");

const QString KPathSeparator("/");

const QString KRecipeRelativePicturePrefix("RecipeRelative"+KPathSeparator);

const QString KIngredientRelativePicturePrefix("IngredientRelative"+KPathSeparator);

/**
 * Table and column(role) definition
 */

/**
 * Cuisine table definition
 */
const QString KTableCuisine("cuisine");
const QString KCuisineId(KCObjectId);
const QString KCuisineParentId("parent_id");
const QString KCuisineName("name");
const QString KCuisineDescription("description");
const QString KCuisineRegionId("region_id");
const QString KCuisinePicture("picture");
const QString KCuisineRecipeCount("recipe_count");//not real column
const QString KCuisinePicturePrefix("Cuisine"+KPathSeparator);

/**
 * Recipe table definition
 */
const QString KTableRecipe("recipe");
const QString KRecipeId(KCObjectId);
//const QString KRecipeCuisineId("cuisine_id");
const QString KRecipeName("name");
const QString KRecipeRepresentative("representative");
const QString KRecipeFlavourId("flavour_id");
const QString KRecipeTechniqueId("technique_id");
const QString KRecipePreparingTime("preparing_time");
const QString KRecipeCookingTime("cooking_time");
const QString KRecipeDifficulty("difficulty");
const QString KRecipeDishTypeId("dish_type_id");
const QString KRecipeFoodTypeId("food_type_id");
const QString KRecipeServe("serve");
const QString KRecipePicture("picture");
const QString KRecipePicturePrefix(KRecipeRelativePicturePrefix
                                   +"Recipe"+KPathSeparator);

/**
 * Cuisine Recipe table definition
 */
const QString KTableCuisineRecipe("cuisine_recipe");
const QString KCuisineRecipeId(KCObjectId);
const QString KCuisineRecipeCuisineId("cuisine_id");
const QString KCuisineRecipeRecipeId("recipe_id");

/**
 * Region table definition
 */
const QString KTableRegion("region");
const QString KRegionId(KCObjectId);
const QString KRegionParentId("parent_id");
const QString KRegionName("name");
const QString KRegionDescription("description");
const QString KRegionPicture("picture");
const QString KRegionPicturePrefix("Region"+KPathSeparator);

/**
 * Flavour table definition
 */
const QString KTableFlavour("flavour");
const QString KFlavourId(KCObjectId);
const QString KFlavourName("name");
const QString KFlavourDescription("description");
const QString KFlavourPicture("picture");
const QString KFlavourPicturePrefix(KRecipeRelativePicturePrefix
                                    +"Flavour"+KPathSeparator);

/**
 * Ingredient table definition
 */
const QString KTableIngredient("ingredient");
const QString KIngredientId(KCObjectId);
const QString KIngredientName("name");
const QString KIngredientDescription("description");
const QString KIngredientCategoryIdentify("category_id");
const QString KIngredientPicture("picture");
const QString KIngredientUnitTypeId("unit_type_id");
const QString KIngredientPicturePrefix(KIngredientRelativePicturePrefix
                                       +"Ingredient"+KPathSeparator);

/**
 * Ingredient category table definition
 */
const QString KTableIngredientCategory("ingredient_category");
const QString KIngredientCategoryId(KCObjectId);
const QString KIngredientCategoryName("name");
const QString KIngredientCategoryDescription("description");
const QString KIngredientCategoryPicture("picture");
const QString KIngredientCategoryPicturePrefix(KIngredientRelativePicturePrefix
                                               + "Category"+KPathSeparator);

/**
 * Technique table definition
 */
const QString KTableTechnique("technique");
const QString KTechniqueId(KCObjectId);
const QString KTechniqueParentId("parent_id");
const QString KTechniqueName("name");
const QString KTechniqueDescription("description");
const QString KTechniquePicture("picture");
const QString KTechniquePicturePrefix(KRecipeRelativePicturePrefix
                                      +"Technique"+KPathSeparator);

/**
 * Dish type table definition
 */
const QString KTableDishType("dishtype");
const QString KDishTypeId(KCObjectId);
const QString KDishTypeParentId("parent_id");
const QString KDishTypeName("name");
const QString KDishTypeDescription("description");
const QString KDishTypePicture("picture");
const QString KDishTypePicturePrefix(KRecipeRelativePicturePrefix
                                     +"DishType"+KPathSeparator);

/**
 * Food type table definition
 */
const QString KTableFoodType("foodtype");
const QString KFoodTypeId(KCObjectId);
const QString KFoodTypeParentId("parent_id");
const QString KFoodTypeName("name");
const QString KFoodTypeDescription("description");
const QString KFoodTypePicture("picture");
const QString KFoodTypePicturePrefix(KRecipeRelativePicturePrefix
                                     +"FoodType"+KPathSeparator);

/**
 * Method table definition
 */
const QString KTableMethod("method");
const QString KMethodId(KCObjectId);
const QString KMethodRecipeId("recipe_id");
const QString KMethodStep("step");
const QString KMethodDescription("description");
const QString KMethodCostTime("costTime");
const QString KMethodPicture("picture");
/*
 * Method picture has special prefix,
 * it's format looks like: Recipe/recipe_id/Method/1.jpg
 */
const QString KMethodPicturePrefix(KRecipeRelativePicturePrefix
                                   +KRecipePicturePrefix
                                   +"%1"+KPathSeparator
                                   +"Methods"+KPathSeparator);

/**
 * Recipe ingredient relation table definition
 */
const QString KTableRecipeIngredient("recipe_ingredient");
const QString KRecipeIngredientId(KCObjectId);
const QString KRecipeIngredientRecipeId("recipe_id");
const QString KRecipeIngredientIngredientId("ingredient_id");
const QString KRecipeIngredientCustomQuantity("custom_quantity");
const QString KRecipeIngredientCustomUnitTypeId("custom_unit_type_id");
const QString KRecipeIngredientQuantity("quantity");


/**
 * Unit type table definition
 */
const QString KTableUnitType("unit_type");
const QString KUnitTypeId(KCObjectId);
const QString KUnitTypeName("name");

///**
// * Category table definition
// */
//const QString KTableCategory("category");
//const QString KCategoryId(KCObjectId);
//const QString KCategoryName("name");
//const QString KCategoryDescription("description");
//const QString KCategoryPicture("picture");
//const QString KCategoryPicturePrefix(KIngredientRelativePicturePrefix + "Category/");

/**
 * Nutrition table definition
 */
const QString KTableNutrition("nutrition");
const QString KNutritionId(KCObjectId);
const QString KNutritionName("name");
const QString KNutritionDescription("description");
const QString KNutritionUnitTypeId("unit_type_id");

/**
 * Ingredient Nutrition table definition
 */
const QString KTableIngredientNutrition("ingredient_nutrition");
const QString KIngredientNutritionId(KCObjectId);
const QString KIngredientNutritionNutritionId("nutrition_id");
const QString KIngredientNutritionIngredientId("ingredient_id");
const QString KIngredientNutritionNutritionQuantity("nutrition_quantity");
const QString KIngredientNutritionIngredientQuantity("ingredient_quantity");

/**
 * Nutrition consume table definition
 */
const QString KTableNutritionConsume("nutrition_consume");
const QString KNutritionConsumeId(KCObjectId);
const QString KNutritionConsumeName("name");
const QString KNutritionConsumeDescription("description");
const QString KNutritionConsumePicture("picture");
const QString KNutritionConsumePicturePrefix("NutritionConsume"+KPathSeparator);

/**
 * Consume Nutrition relation table definition
 */
const QString KTableConsumeNutrition("consume_nutrition");
const QString KConsumeNutritionId(KCObjectId);
const QString KConsumeNutritionConsumeId("consume_id");
const QString KConsumeNutritionNutritionid("nutrition_id");
const QString KConsumeNutritionQuantity("quantity");

/**
 * Meal table definition
 */
const QString KTableMeal("meal");
const QString KMealId(KCObjectId);
const QString KMealName("name");
const QString KMealDescription("description");
const QString KMealScheduleTime("schedule_time");
const QString KMealStatus("status");

/**
 * Meal recipe relation table definition
 */
const QString KTableMealRecipe("meal_recipe");
const QString KMealRecipeId(KCObjectId);
const QString KMealRecipeMealId("meal_id");
const QString KMealRecipeRecipeId("recipe_id");
const QString KMealRecipeStatus("status");

/**
 * Tip table definition
 */
const QString KTableTip("tip");
const QString KTipId(KCObjectId);
const QString KTipRecipeId("recipe_id");
const QString KTipNumber("name");
const QString KTipDescription("description");

/**
 * Shopping list definition
 */
const QString KTableShoppingList("shopping_list");
const QString KShoppingListId(KCObjectId);
const QString KShoppingListName("name");
const QString KShoppingListDescription("description");

/**
 * Shopping list item relationship table
 */
const QString KTableListItem("list_item");
const QString KListItemId(KCObjectId);
const QString KListItemListId("list_id");
const QString KListItemItemId("item_id");
const QString KListItemItemType("item_type");
const QString KListItemName("name");//not real
const QString KListItemQuantity("quantity"); //not real
const QString KListItemPurchasedQuantity("purchased_quantity");
const QString KListItemUnitTypeId("unit_type_id");//not real
const QString KListItemDescription("description");

/**
 * Shopping list item source table
 */
const QString KTableItemSource("item_source");
const QString KItemSourceId(KCObjectId);
const QString KItemSourceListItemId("list_item_id");
const QString KItemSourceSourceType("source_type");
const QString KItemSourceSourceId("source_id");
const QString KItemSourceQuantity("quantity");

/**
 * Custom item table
 */
const QString KTableCustomItem("custom_item");
const QString KCustomItemId(KCObjectId);
const QString KCustomItemName("name");
const QString KCustomItemUnitTypeId("unit_type_id");
} // namespace cooking
#endif // CCONSTDEFINITION_H

